package com.anteater.eattheant;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.Button;
import android.widget.TextView;

import com.anteater.eattheant.util.SoundPlayer;

public class OptionsActivity extends Activity {

	private AbsoluteLayout layout;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);

		setContentView(R.layout.options);
		createButtons();
	}

	private void createButtons() {
		layout = (AbsoluteLayout) findViewById(R.id.optionslayout);
		TextView t = (TextView) findViewById(R.id.textView1);

		layout.removeAllViews();
		t.setTextColor(Color.BLACK);
		layout.addView(t, new AbsoluteLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 110,110));
		
		Button b = new Button(this);
		
		if (SoundPlayer.getInstance().isSoundEnable()) {
			b.setBackgroundResource(R.drawable.sound_off);
			b.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					SoundPlayer.getInstance().stopSounds();
					createButtons();
				}
			});
		} else {
			b.setBackgroundResource(R.drawable.sound_on);
			b.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					SoundPlayer.getInstance().startSounds();
					createButtons();
				}
			});
		}
		layout.addView(b, new AbsoluteLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 620,90));
	}

}
